package my.springboot.event;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
 * 要使用spring的事件监听机制，当然要将事件接收的Bean放入容器中托管才行
 * @author xsw
 */
@Component
public class DemoListener implements ApplicationListener<DemoEvent> {

	@Override
	public void onApplicationEvent(DemoEvent de) {
		String message = de.getMessage();
		System.out.println("监听到事件："+message);
	}

}
